package mylab.starters.dag.graph.impl;

import lombok.Getter;
import mylab.starters.dag.graph.Edge;
import mylab.starters.dag.graph.Vertex;


@Getter
public class BaseEdge implements Edge {
    protected Vertex from;
    protected Vertex to;

    public BaseEdge(Vertex from, Vertex to) {
        this.from = from;
        this.to = to;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Edge edge) {
            return getFrom().equals(edge.getFrom()) && getTo().equals(edge.getTo());
        }
        return false;
    }

    @Override
    public int hashCode() {
        return String.format("%s_%s", getFrom().getId(), getTo().getId()).hashCode();
    }
}
